﻿@model Sheng.WeixinConstruction.Management.Shell.Models.MemberGroupMessageViewModel

@{
    ViewBag.MainMenu = "Member";
    ViewBag.LeftMenu = "GroupMessage";
    
    ViewBag.Title = "群发功能";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script>

    function send()
    {
        if (__validateMaterialSelect() == false)
            return;

        var confirmLayerIndex = layer.confirm("注意：订阅号每天一条群发权限，服务号每月（自然月）四条群发权限，是否确认提交发送？", {
            btn: ['确认', '取消'], //按钮
            shade: [0.4, '#393D49'],
            title: false,
            closeBtn: false,
            shift: _layerShift
        }, function ()
        {
            layer.close(confirmLayerIndex);

            var loadLayerIndex = layer.load(0, {
                shade: [0.2, '#fff']
            });

            var args = new Object();
            args.GroupId = $("#selectGroupList").children('option:selected').val();
            args.Type = __materialType;
            args.Content = __getMaterialText();
            if (__materialImage != undefined && __materialImage != null)
            {
                args.Name = __materialImage.Name;
                args.Url = __materialImage.Url;
                args.MediaId = __materialImage.MediaId;
            }
            args.ArticleId = __materialArticleId;

            var url = "/Api/Member/SendGroupMessage";

            $.ajax({
                url: url,
                type: "POST",
                dataType: "json",
                data: JSON.stringify(args),
                success: function (data, status, jqXHR)
                {
                    layer.close(loadLayerIndex);
                    if (data.Success)
                    {
                        layerAlert("提交成功，群发任务一般需要较长的时间才能全部发送完毕，请耐心等待。", function ()
                        {
                            window.location.href = "/Member/SentGroupMessage";
                        });
                    } else
                    {
                        layerAlert(data.Message);
                    }
                },
                error: function (xmlHttpRequest)
                {
                    layer.close(loadLayerIndex);
                    alert("Error: " + xmlHttpRequest.status);
                }
            });
        });

        
    }

</script>

<div id="divContentTips">
    向您的会员推送消息。
</div>

<div style=" margin-top:20px;">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td class="td_ContentTab_active" style="width:200px;">新建群发消息</td>
            <td class="td_ContentTab" style="width:200px;"><a href="/Member/SentGroupMessage" class="a_black_16">已发送</a></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td colspan="4" bgcolor="#EEEEEE" height="2"></td>
        </tr>
    </table>
</div>

<div style="margin-left:20px; margin-right:20px;">


    <div style=" margin-top:10px;">
        <table width="100%" border="0" cellspacing="0" cellpadding="8">
            <tr>
                <td width="80">群发对象：</td>
                <td width="220">
                    <select id="selectGroupList" class="input_16" style="min-width:100px;">
                        <option value="-1">全部</option>
                        @foreach (var item in Model.MemberGroupList)
                        {
                            <option value="@item.GroupId" >@item.Name</option>
                        }
                    </select>
                </td>
                <td width="80"></td>
                <td width="220"></td>
                <td></td>
                <td width="100" align="right"></td>
            </tr>
        </table>
    </div>

    @Helpers.MaterialSelect(true,true,true)

    <div style=" margin-top:25px;">
        <input name="btnSave" type="button" class="btn_blue" id="btnSave" value="发 送" onclick="send()" />
    </div>

</div>

